package com.tl.mq.kafka_mq;

import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

@Component
public class KafkaConsumer {

    @KafkaListener(topics = {"test_topic"})
    public void consumerMsg(String message){

        System.out.println("消费消息： " + message);

    }

    // 手动确认
    @KafkaListener(topics = {"test_topic"},containerFactory = "kafkaManualAckListenerContainerFactory")
    public void consumerMsg(String message, Acknowledgment ack){

        System.out.println("消费消息： " + message);
        ack.acknowledge();

    }


}
